package com.yh.blog.domain;

import lombok.Data;
import lombok.ToString;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 博客实体类
 */
@Data
@ToString
public class Blog {
    private Integer blogId;
    private String title;
    private String content;
    private String description;
    private String img;
    private String flag;
    private int views;
    private int comment_count;
    private Date create_time;
    private Date update_time;
    private int typesId;
    private String typesName;
    private int userId;
    private String userImg;
    private String nickname;
    private Users user;
    private Types type;
    private boolean money_open;
    private boolean comment_open;
    private boolean recommend_open;
    private boolean share_open;
    private boolean publish;
    private List<Comments> comments=new ArrayList<>();

//    在pojo中定义一个时间转换方法，不然前台展示的时间是英式时间
    public String formateTime(Date date) {
        SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return df.format(date);
    }

    public String formateTime2(Date date) {
        SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
        return df.format(date);
    }
}
